﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@model IEnumerable<MockSchoolManagement.Core.ApplicationUser>
@{
    ViewBag.Title = "用户列表";
}
<h1>所有用户</h1>

@if (Model.Any())
{
    <a asp-action="Register" asp-controller="Account" class="btn btn-primary mb-3" style="width: auto">创建用户</a>
    foreach (var user in Model)
    {
        <div class="card mb-3">
            <div class="card-header">
                用户ID：@user.Id
            </div>
            <div class="card-body">
                <h5 class="card-title">@user.UserName</h5>
            </div>
            <div class="card-footer">
                <form method="post" asp-action="DeleteUser" asp-route-id="@user.Id">

                    <a asp-action="EditUser" asp-route-id="@user.Id" class="btn btn-primary">编辑</a>
                    <span id="confirmDeleteSpan_@user.Id" style="display: none">
                        <span>你确定要删除？</span>
                        <button type="submit" class="btn btn-danger">是</button>
                        <a href="#" class="btn btn-primary" onclick="confirmDelete('@user.Id',false)">否</a>
                    </span>
                    <span id="deleteSpan_@user.Id">
                        <a href="#" class="btn btn-danger" onclick="confirmDelete('@user.Id',true)">删除</a>
                    </span>
                </form>
            </div>

        </div>
    }
}
else
{
    <div class="card">
        <div class="card-header">尚未创建用户</div>
        <div class="card-body">
            <h5 class="card-title">
                单击下面的按钮创建用户
            </h5>
            <a class="btn btn-primary" asp-controller="Account" asp-action="Register">创建用户</a>
        </div>
    </div>
}
@section Scripts
{
    <script src="~/js/CustomScript.js" asp-append-version="true"></script>
}
